//
//  TabBarController.m
//  第三组_阅读器
//
//  Created by My Mac on 2016/12/25.
//  Copyright © 2016年 My Mac. All rights reserved.
//

#import "TabBarController.h"
#import "RootViewController.h"
#import "CommonViewController.h"
#import "NavigationController.h"
@interface TabBarController ()

@end

@implementation TabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    RootViewController * rootView = [[RootViewController alloc]init];
    [self setAChildViewController:rootView tabBarTitle:@"书架模式" navigationTitle:@"我的书架" imageName:@"书架"];
    
    CommonViewController * commonView = [[CommonViewController alloc]init];
    [self setAChildViewController:commonView tabBarTitle:@"普通模式" navigationTitle:@"我的书籍" imageName:@"普通"];
}
-(void)setAChildViewController:(UIViewController *)viewController tabBarTitle:(NSString *)tabBarTitle navigationTitle:(NSString *)navTitle imageName:(NSString *)imageName{
    NavigationController * nav = [[NavigationController alloc]initWithRootViewController:viewController];
    nav.title = tabBarTitle;
    viewController.navigationItem.title = navTitle;
    [self setImageName:imageName navController:nav];
    [self addChildViewController:nav];
}
-(void)setImageName:(NSString *)imageName navController:(NavigationController *)nav
{
    UIImage * image = [UIImage imageNamed:imageName];
    image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    nav.tabBarItem.image = image;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}
@end
